The present invention relates generally to computer-readable, parsable structures and, in particular, to the extension of parsable structures using external objects that communicate with the parsable structure via a bilateral interface.
Various computer languages are well known in the art. For example, there are so-called xe2x80x9cmarkupxe2x80x9d languages that provide a method of adding information to text in a computer-displayed document indicating the logical components of the document, or that provide instructions for the layout of text on the page or other information that can be interpreted by a computer. A particular example of a markup language is the so-called Extensible Markup Language (XML) that, in essence, makes data self-describing. XML provides a standardized approach that allows programmers to surround information with markup (i.e., xe2x80x9ctagsxe2x80x9d) that describes what the data is, not just what it should look like or where it should be positioned. Using XML, documents can be created that are easily processed by computers that follow the relatively simple rules for interpreting XML xe2x80x9ccodexe2x80x9d. To this end, an XML parser (an algorithm or program to determine the syntactic structure of a sentence or string of symbols written in some language) can be used to break down an XML document into a representation that a computer can understand.
A further feature of XML is the use of so-called xe2x80x9cschemasxe2x80x9d. Schemas are an example of meta-data (data that describes other data), and are used in XML in part to describe the proper syntax for a document. For example, a schema can describe which records are permitted in a given database, which fields can be in a given record, what data types are allowed for a given field, etc. Using a schema included in a document, an XML parser can ensure that the remainder of the document follows the rules set forth in the schema. This is useful to ensure that a given document conforms to an agreed-upon format.
XML markup and schemas are powerful tools to programmers. However, specific XML grammars are not currently extensible. For example, there is an XML grammar called XML Stylesheet Language (XSL) that is used for defining document conversion. An XSL stylesheet can take one XML document and convert it to something else, by processing the various nodes in the XML source document. For example, a simple XML database could be converted to a Hypertext Markup Language (HTML) page that would display the information in the database. XSL operates by having a program that reads and then interprets the XSL commands. Today, the set of commands is fixed and the functionality expressible by the language is therefore fixed. Likewise, XML schemas are extensible in the sense that the schema language is language for describing a very broad set of document structures. Like XSL, however, the keywords used in the schema description are fixed and functionality expressed by the schema is therefore fixed.
Traditional programming languages (and declarative languages such as XSL) typically provide extensibility either through classes or objects, as known in the art. For example, a C++ programmer can create a new class containing functionality. That class can be instantiated within a program and used. Alternatively, a programmer using the xe2x80x9cVISUAL BASICxe2x80x9d development system can add an Object Linking and Embedding (OLE) custom control (OCX; often referred to as ActiveX controls) to a program and call the methods available on the OCX. These functions and controls, while useful, only perform a specific function and return when executed. They do not allow a developer to alter program execution and flow.
Many languages provide a fixed set of symbols (such as xe2x80x9cforxe2x80x9d, xe2x80x9cwhilexe2x80x9d, xe2x80x9cifxe2x80x9d, etc.) often referred to as keywords that do allow a developer to control the execution and flow within a program and to manipulate (assign, compare, etc.) data. Keywords are what form a programming language. For example, C++ is a collection of keywords and their associated behavior (for, while, if, etc.); likewise, BASIC is a collection of keywords and their associated behavior (FOR, SELECT, IF, etc.). However, because the set of keyword symbols is fixed, developers are restricted to the functionality provided by the fixed set. Although additional functionality can be added by virtue of functions and controls, they are not capable of altering execution and flow of a program as noted above. This is illustrated by the following example.
Assume, for example, that a programmer wants to create a loop that would go through the first four records in a database for people named Fred, and then process them in some manner. Such code could be written as shown in Table 1.
The code set forth in Table 1 sets forth an example of specialized looping capability defined by a particular xe2x80x9cwhilexe2x80x9d loop, although any number of processing steps (e.g., xe2x80x9cprocessData( )xe2x80x9d and xe2x80x9cprintData( )xe2x80x9d) could be performed within the loop. Now further assume that this functionality needs to be provided to other developers. Optimally, one would want to provide the functionality for everything but the processing steps, as shown in Table 2.
As used in Table 2, xe2x80x9cFredWhilexe2x80x9d functions as a keyword, i.e., a customized version of the typical xe2x80x9cwhilexe2x80x9d keyword. The looping capability has been made generic in the form of the xe2x80x9cFredWhilexe2x80x9d0 keyword, while still providing the flexibility to perform any number of processing steps within the loop. Stated another way, the xe2x80x9cFredWhilexe2x80x9d customized keyword represents a new way in which a programmer can alter program execution and flow. However, programmers are currently unable to provide such customized functionality in this manner. The best one can do using current techniques is to pass function pointer arguments, as illustrated in Table 3.
In the example shown in Table 3, the looping capability has been made generic through the provision of the xe2x80x9cFredWhilexe2x80x9d function. However, it is limited to two pointer argument inputs (*p1 and *p2) and therefore has little flexibility in the number of processing steps that can be performed within the loop. This could be extended using variable argument lists, but that is also problematic. Furthermore, neither approach works well with general contained logic, where one might want additional execution flow to determine which contained functions execute.
Thus, it would be advantageous to provide a technique whereby parsable structures (such as XML trees or structures created in other languages) can be extended to include external objects providing additional functionality. Furthermore, a need exists for a technique that enables programmers to define and use customized keywords.
The present invention provides a technique for extending parsable structures to include external objects. The present invention also facilitates the addition of customized keywords to parsable structures. To this end, a bilateral interface is provided. The bilateral interface may comprise an object interface and, optionally, a language interface. The object interface comprises at least an object-side object interface to be included in an external object, and a structure-side object interface to be included in a parsable structure. The inclusion of the object-side object interface in an external object indicates that the object is suitable for inclusion in a parsable structure comprising the structure-side object interface. When executed, an object initialization routine included in the object-side object interface provides an identification of the structure-side object interface to the object. Conversely, a structure initialization routine included in the structure-side object interface provides an identification of at least one interaction routine to the object. The external object can then invoke the at least one interaction routine to interact with the parsable structure.
The language interface is similarly constructed comprising an object-side language interface included in the external object and a structure-side language interface included in the parsable structure. A language initialization routine within the object-side language interface provides an identification of the structure-side language interface to the external object. Once the structure-side language interface has been identified to the external object, an execution routine resident in the object-side language interface can invoke at least one language interaction routine resident in the structure-side language interface.
In this manner, the present invention provides much greater extensibility for parsable structures than was previously possible. Using these techniques, programmers can add customized keywords, thereby significantly increasing the flexibility of a given computer language. As known in the art, language engines have several pieces: a parser for reading through the language, and a compiler or interpreter for executing the language. The present invention provides a means by which external objects can interact with a language engine during these various phases so as to implement new keywords and new functionality previously unanticipated. For example, with regard to XSL, the present invention allows new keywords to be added. With regard to schemas, the present invention provides for the addition of new validation. This interaction can occur during a parse, compilation or interpretive execution stage.